package com.atguigu.tingshu.dispatch.helper;

import com.atguigu.tingshu.search.client.SearchFeignClient;
import com.atguigu.tingshu.user.client.UserFeignClient;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class DispatchJobHandler {

    @Autowired
    private SearchFeignClient searchFeignClient;

    @Autowired
    private UserFeignClient userFeignClient;

    @XxlJob("firstJobHandler")
    public void firstJobHandler() {
        log.info("xxl-job项目集成测试");
        log.info("测试任务执行>>>>>>>>>>>>>>>>>>>>>>>");
    }


    /**
     * 定时执行热门专辑更新
     */
    @XxlJob("updateHotAlbumJob")
    public void updateHotAlbumJob() {
        log.info("定时执行热门专辑更新>>>>>>>>>>>>>>>>>>>>>>>");
        searchFeignClient.updateLatelyAlbumRanking();
    }

    /**
     * 定时执行更新会员状态
     * @return
     */
    @XxlJob("updateUserVIPStatusJob")
    public void updateUserVIPStatusJob() {
        log.info("定时更改用户vip状态>>>>>>>>>>>>>>>>>>>>>>>");
        userFeignClient.updateVipExpireStatus();
    }
}